<style>
	table{
		border-collapse:collapse;
		width:100%;
	}
	tr td{
		padding:2px;
	}
	tr.main_header td{
		border-bottom:2px solid #000;
	}
	tr.center td{
		text-align:center;
		background:#E6E6E6;
	}
	tr.sub_total td{
		background:#F3F3F3;
	}
	tr.total td{
		border:1px solid #000;
	}
	tr.heading td{
		background:none;
		font-weight:bold;
		font-size:14px;
		text-transform:uppercase;
	}
	.left{ text-align:left;}
	.right{ text-align:right;}
</style>

<?if(!empty($report)):?>
	<table>
		<thead>
			<tr class="center heading">
				<td colspan="4">Payment Report month of <?=date('F Y',mktime(0,0,0,$month,0,$year));?></td>
			</tr>
			<tr class="main_header center">
				<td>Student Name</td>
				<td>Student Id</td>
				<td>Level</td>
				<td>Amount Paid</td>
			</tr>
		</thead>
	<?foreach($report as $k => $v):?>
		<tbody>
			<?if($v !== NULL):?>
			<thead>
				<tr class="center">
					<td colspan="4">[ <?=$k;?> ]&nbsp;<?=date('l',mktime(0,0,0,0,$k,0));?></td>
				</tr>
			</thead>
				<?foreach($v as $v):?>
					<?$sum[] = $v->amt_paid;?>
					<?$ssum[$k][] = $v->amt_paid;?>
					<tr>
						<td><?=$v->fullname;?></td>
						<td><?=$v->id;?></td>
						<td><?=$v->grade_level;?></td>
						<td class="right"><?=number_format($v->amt_paid,2,'.',',');?></td>
					</tr>
				<?endforeach;?>
					<tr class="sub_total">
						<td colspan="3">Subtotal</td>
						<td class="right"><?=number_format(array_sum($ssum[$k]),2,'.',',');?></td>
					</tr>
			<?endif;?>
		</tbody>
	<?endforeach;?>
		<tbody>
			<tr class="total">
				<td colspan="3">Total</td>
				<?if(isset($sum)):?>
					<td class="right"><?=number_format(array_sum($sum),2,'.',',');?></td>
				<?else:?>
					<td>0.00</td>
				<?endif;?>
			</tr>
			<tr  class="center">
				<td colspan="4">***********  Nothing Follows  ***********</td>
			</tr>
		</tbody>
	</table>
<?else:?>
	<div class="alert alert-notice">
		No Data!
	</div>
<?endif;?>